﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Data.ProviderBase;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Windows;
using System.Data.Sql;
using System.IO;

using System.Data.SqlServerCe;



namespace WowCharacters
{
    public partial class WoWForm : Form
    {
        PictureBox[] Icons = new PictureBox[20];
        System.Windows.Forms.ToolTip toolTip = new System.Windows.Forms.ToolTip();
        Character LC = new Character();
        DataGridView[] StatsPane =  new DataGridView[2];
        LoadFromWeb FRM = new LoadFromWeb();
        
        public WoWForm()
        {

               FRM.WowFrm = this;
               InitializeComponent();
               StatsPane[0]=dataGridView1;
               StatsPane[1] = dataGridView2;

               Icons[0] = HeadIcon0;
               Icons[1] = NeckIcon1;
               Icons[2] = ShoulderIcon2;
               Icons[3] = ShirtIcon3;
               Icons[4] = ChestIcon4;
               Icons[5] = WaistIcon5;
               Icons[6] = LegsIcon6;
               Icons[7] = FeetIcon7;
               Icons[8] = WristIcon8;
               Icons[9] = HandsIcon9;
               Icons[10] = Finger1Icon10;
               Icons[11] = Finger2Icon11;
               Icons[12] = Trinket1Icon12;
               Icons[13] = Trinket2Icon13;
               Icons[14] = BackIcon14;
               Icons[15] = MainhandIcon15;
               Icons[16] = OffhandIcon16;
               Icons[17] = RangedIcon17;
               Icons[18] = TabardIcon18;
               Icons[19] = AmmoIcon19;

               dataGridView1.Rows.Clear();
               dataGridView2.Rows.Clear();

        }
          public void GetCharacterfromWeb(string character, string server)
        {
            SqlCeConnection Test = new SqlCeConnection("Data Source = WowCharacters.sdf");
            SqlCeCommand cmd = Test.CreateCommand();
            cmd.CommandText = "SELECT ID, Name, Server FROM Character";
            SqlCeDataAdapter da = new SqlCeDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
       
           
            var charQue = (from o in ds.Tables["Table"].AsEnumerable().Distinct()
                          select new
                          {
                             // ID = o.Field<int>("ID"),
                              //Name = o.Field<string>("Name"),
                              Server = o.Field<string>("Server")
                          }).Distinct();
            foreach (var Ch in charQue)
            {
                TreeNode ServerName = treeView1.Nodes.Add(Ch.Server);
                var CharChar = (from o in ds.Tables["Table"].AsEnumerable().Distinct()
                                where o.Field<string>("Server") == Ch.Server
                                select new
                                {
                                    // ID = o.Field<int>("ID"),
                                    Name = o.Field<string>("Name"),
                                    //Server = o.Field<string>("Server")
                                }).Distinct();
                foreach (var CHCH in CharChar)
                {
                    ServerName.Nodes.Add(CHCH.Name);
                }
            }

 
            

            LoadCharacter LCharacter1 = new LoadCharacter(character, server);
            LC = LCharacter1.GetCharaterStats();
            setcharacter();
           

        }
        private void GetCharcterFromFile()
        {
            FileStream file = new FileStream(openFileDialog1.FileName, FileMode.Open);
            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            LC = bf.Deserialize(file) as Character;
            file.Close();
            setcharacter();
        }
        private void setcharacter()
        {
            if (LC.error == "noCharacter")
            {
                MessageBox.Show("Character or Server name invalid. Please try again.");
            }
            else if (LC.error == "Character Not Updated")
            {
                MessageBox.Show("Character has not been synced, please login to the game to sync");
            }
            else
            {
                
                comboBox1.SelectedIndex = 0;
                comboBox2.SelectedIndex = 1;
                UpdateBaseStats(0);
                UpdateMeleeStats(1);
                UpdateCharInfo();
                UpdateTradeskills();
                UpdateBars();
                updateIcons();
                updateResists();
                updateTalantSpec();
                //Stream a = File.OpenWrite("C:\\serialize.text");
                //System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                //bf.Serialize(a, LC);
                // a.Close();

            }
        }
            
            
        private void updateIcons()
        {
            // Items
            for (int i = 0; i < 20; i++)
            {
                if (LC.CIT[i].druability != null)
                {
                    toolTip.SetToolTip(Icons[i], LC.CIT[i].itemname);

                    Icons[i].Image = Image.FromFile(LC.CIT[i].file);
                }
                else
                {
                    toolTip.SetToolTip(Icons[i], "");
                    Icons[i].Image = null;
                    Icons[i].Invalidate();
                   
                }
            }
        }
        private void updateResists()
        {
            picArcane.Image = Image.FromFile(LC.CR.Arcane_Image);
            picArcane.Text = LC.CR.Arcane;
            picFire.Image = Image.FromFile(LC.CR.Fire_Image);
            picFire.Text = LC.CR.Fire;
            picNature.Image = Image.FromFile(LC.CR.Nature_Image);
            picNature.Text = LC.CR.Nature;
            picFrost.Image = Image.FromFile(LC.CR.Frost_Image);
            picFrost.Text = LC.CR.Frost;
            picShadow.Image = Image.FromFile(LC.CR.Shadow_Image);
            picShadow.Text = LC.CR.Shadow;

        }
        private void updateTalantSpec()
        {
            int[] specValue = new int[3];
            specValue[0] = Convert.ToInt32(LC.CT.TreeOne_Value);
            specValue[1] = Convert.ToInt32(LC.CT.TreeTwo_Value);
            specValue[2] = Convert.ToInt32(LC.CT.TreeThree_Value);
            string[] specName = new string[3];
            specName[0] = LC.CT.TreeOne;
            specName[1] = LC.CT.TreeTwo;
            specName[2] = LC.CT.TreeThree;
            string[] specIMage = new string[3];
            specIMage[0] = LC.CT.TreeOne_Image;
            specIMage[1] = LC.CT.TreeTwo_Image;
            specIMage[2] = LC.CT.TreeThree_Image;

            lbltalents.Text = LC.CT.TreeOne_Value + " / " + LC.CT.TreeTwo_Value + " / " + LC.CT.TreeThree_Value;

            if (specValue[0] > specValue[1])
            {
                if (specValue[0] > specValue[2])
                {
                    lblTalentSpec.Text = specName[0];
                    picSpec.Image = Image.FromFile(specIMage[0]);
                }
                else
                {
                    lblTalentSpec.Text = specName[2];
                    picSpec.Image = Image.FromFile(specIMage[2]);
                }
            }
            else
            {
                if (specValue[1] > specValue[2])
                {
                    lblTalentSpec.Text = specName[1];
                    picSpec.Image = Image.FromFile(specIMage[1]);
                }
                else
                {
                    lblTalentSpec.Text = specName[2];
                    picSpec.Image = Image.FromFile(specIMage[2]);
                }
            }

            
        }
        private void UpdateBars()
        {
            LblHealth.Text = LC.CB.Health;
            Lbl2ndBar.Text = LC.CB.SecBar_effective;
            Lbl2ndBarName.Text = LC.CB.SecBar_type + ":";
            Lbl2ndBar.BackColor = LC.CB.SecBar_Color;

        }

        private void UpdateTradeskills()
        {
            LblTrade1Text.Text = LC.CTS.P1_Name + ": " + LC.CTS.P1_Value + "/" + LC.CTS.P1_max;
            Trade1Icon.Image = Image.FromFile(LC.CTS.P1_Icon);
            LblTrade2Text.Text = LC.CTS.P2_Name + ": " + LC.CTS.P2_Value + "/" + LC.CTS.P2_Max;
            Trade2Icon.Image = Image.FromFile(LC.CTS.P2_Icon);
            if (LC.CTS.P1_Name == "None")
            {
            LblTrade1Text.Text = LC.CTS.P1_Name + ": N/A";
            Lbltrade1fill.Width = 1;
            }
            else
            {
                Lbltrade1fill.Width = Convert.ToInt32(((Convert.ToDecimal(LC.CTS.P1_Value) / Convert.ToDecimal(LC.CTS.P1_max)) * 178));
            }
            if (LC.CTS.P2_Name == "None")
            {
                LblTrade2Text.Text = LC.CTS.P2_Name + ": N/A";
                lbltrade2fill.Width = 1;
            }
            else
            {
                lbltrade2fill.Width = Convert.ToInt32(((Convert.ToDecimal(LC.CTS.P2_Value) / Convert.ToDecimal(LC.CTS.P2_Max)) * 178));
            }
        }

        private void UpdateMeleeStats(int grid)
        {
            
             StatsPane[grid].Rows.Clear();
             StatsPane[grid].Rows.Add("Main Damage:", LC.CMS.MH_min + "-" + LC.CMS.MH_max);
             StatsPane[grid].Rows.Add("Main Speed:", LC.CMS.MH_HasteSpeed);
            // StatsPane[grid].Rows.Add("Off Damage:", LC.CMS.OH_min + "-" + LC.CMS.OH_max);
             //StatsPane[grid].Rows.Add("Off Speed", LC.CMS.OH_HasteSpeed);
             StatsPane[grid].Rows.Add("Power:", LC.CMS.AP_effective);
             StatsPane[grid].Rows.Add("Hit Raiting:", LC.CMS.Hit_Value);
             StatsPane[grid].Rows.Add("Crit Chance:", LC.CMS.Crit_Percent + "%");
             StatsPane[grid].Rows.Add("Expertise:", LC.CMS.Exp_value);
             for (int i = 0; i < 2; i++)
             {
                 StatsPane[grid].Rows[0].Cells[i].ToolTipText =
                    "Main Hand\n" +
                    " Attack Speed (seconds):   " + LC.CMS.MH_speed + "\n" +
                    " Damage:                      " + LC.CMS.MH_min + "-" + LC.CMS.MH_max + "\n" +
                    " Damage per Second:        " + LC.CMS.MH_dps;
                 StatsPane[grid].Rows[1].Cells[i].ToolTipText =
                    "Main Hand Attack Speed " + LC.CMS.MH_HasteSpeed + "\n" +
                    "   Haste Rating " + LC.CMS.MH_HasteRate + " (" + LC.CMS.MH_hasteper + "% haste)";
                 /*
                  if (Icons[16].Image == null)
                 {
                     dataGridView2.Rows[2].Cells[i].ToolTipText =
                         "Off Hand\n" +
                         " Attack Speed (seconds):   " + LC.CMS.OH_speed + "\n" +
                         " Damage:                      " + LC.CMS.OH_min + "-" + LC.CMS.OH_max + "\n" +
                         " Damage per Second:        " + LC.CMS.OH_dps;
                     dataGridView2.Rows[3].Cells[i].ToolTipText =
                        "Off Hand Attack Speed " + LC.CMS.OH_HasteSpeed + "\n" +
                        "   Haste Rating " + LC.CMS.OH_HasteRate + " (" + LC.CMS.OH_hasteper + "% haste)";
                 }
                 else { }
                  */   
                 StatsPane[grid].Rows[2].Cells[i].ToolTipText =
                    "Melee Attack Power " + LC.CMS.AP_effective + " (" + LC.CMS.AP_Base + " + " + (Convert.ToInt32(LC.CMS.AP_effective) - Convert.ToInt32(LC.CMS.AP_Base)) + ")\n" +
                    " Increases damage with melee weaspons by " + LC.CMS.AP_DPS + "\n" +
                    " damage per second";
                 StatsPane[grid].Rows[3].Cells[i].ToolTipText =
                     "Hit Rating " + LC.CMS.Hit_Value + "\n" +
                     "  Increases your meelee chance to hit a target of\n" +
                     "  (current level) by " + LC.CMS.Hit_Percent + "%";
                 StatsPane[grid].Rows[4].Cells[i].ToolTipText =
                    "Crit Chance " + LC.CMS.Crit_Percent + "%\n" +
                    "  Crit Rating " + LC.CMS.Crit_Rating + " (+" + LC.CMS.Crit_plusPercent + "% crit chance)";
                 StatsPane[grid].Rows[5].Cells[i].ToolTipText =
                    "Expertise Rating " + LC.CMS.Exp_Rating + "%\n" +
                    "  Reduces chance to be dodged or parried by\n"+
                    "  " + LC.CMS.Exp_percent + "%\n" +
                    "  Expertise Rating " + LC.CMS.Exp_Rating + " (+" + LC.CMS.Exp_Add + " expertise)";
            }
   

        }
        private void UpdateRangedStats(int grid)
        {

            StatsPane[grid].Rows.Clear();
            StatsPane[grid].Rows.Add("Damage:", LC.CRS.D_Min + "-" + LC.CRS.D_Max);
            StatsPane[grid].Rows.Add("Speed:", LC.CRS.S_Value);
            StatsPane[grid].Rows.Add("Power:", LC.CRS.P_Effective);
            StatsPane[grid].Rows.Add("Hit Raiting:", LC.CRS.Hit_Value);
            StatsPane[grid].Rows.Add("Crit Chance:", LC.CRS.Crit_Percent + "%");
            for (int i = 0; i < 2; i++)
            {
                StatsPane[grid].Rows[0].Cells[i].ToolTipText =
                   "Ranged\n" +
                   " Attack Speed (seconds):   " + LC.CRS.D_Speed + "\n" +
                   " Damage:                      " + LC.CRS.D_Min + " - " + LC.CRS.D_Max + "\n" +
                   " Damage per Second:        " + LC.CRS.D_DPS;
                StatsPane[grid].Rows[1].Cells[i].ToolTipText =
                   "Attack Speed " + LC.CRS.S_Value + "\n" +
                   "   Haste Rating " + LC.CRS.S_HasteRate + " (" + LC.CRS.S_HastePEr + "% haste)";
                StatsPane[grid].Rows[2].Cells[i].ToolTipText =
                   "Ranged Attack Power " + LC.CRS.P_Effective + " (" + LC.CRS.P_Base + " + " + (Convert.ToInt32(LC.CRS.P_Effective) - Convert.ToInt32(LC.CRS.P_Base)) + ")\n" +
                   " Increases damage with ranged weaspons by " + LC.CRS.P_increasedDps + "\n" +
                   " damage per second.\n" +
                   " Increases your pet's Attack Power by " + LC.CRS.P_PetAttack + "\n" +
                   " Increases your pet's Spell Damage by " + LC.CRS.P_PetSpell;

                StatsPane[grid].Rows[3].Cells[i].ToolTipText =
                    "Hit Rating " + LC.CRS.Hit_Value + "\n" +
                    "  Increases your meelee chance to hit a target of\n" +
                    "  (current level) by " + LC.CRS.Hit_Percent + "%";
                StatsPane[grid].Rows[4].Cells[i].ToolTipText =
                   "Crit Chance " + LC.CRS.Crit_Percent + "%\n" +
                   "  Crit Rating " + LC.CRS.Crit_Rating + " (+" + LC.CRS.Crit_plusPercent + "% crit chance)";
  
            }


        }
        private void UpdateSpellStats(int grid)
        {

            StatsPane[grid].Rows.Clear();

            StatsPane[grid].Rows.Add("Bonus Damage:", LC.CSS.BDamage_Arcane); //need to eventually get min of all
            StatsPane[grid].Rows.Add("Bonus Healing:", LC.CSS.BHealing);
            StatsPane[grid].Rows.Add("Hit Raiting:", LC.CSS.Hit_Value);
            StatsPane[grid].Rows.Add("Crit Chance:", LC.CSS.Crit_Arcane + "%"); // neet to eventually get min of all 
            StatsPane[grid].Rows.Add("Penetration:", LC.CSS.Penetration);
            StatsPane[grid].Rows.Add("Mana Regen:", LC.CSS.MP5_Noncast);

            for (int i = 0; i < 2; i++)
            {
                StatsPane[grid].Rows[0].Cells[i].ToolTipText =
                    "Bonus Damage " + LC.CSS.BDamage_Arcane + '\n' + //need to eventually get min of all
                    " Holy              " + LC.CSS.BDamage_Holy + "\n" +
                    " Fire              " + LC.CSS.BDamage_Fire + "\n" +
                    " Nature            " + LC.CSS.BDamage_Nature + "\n" +
                    " Frost             " + LC.CSS.BDamage_Frost + "\n" +
                    " Shadow            " + LC.CSS.BDamage_Shadow + "\n" +
                    " Arcane            " + LC.CSS.BDamage_Arcane + "\n" +
                    "\n" +
                    "Your " + LC.CSS.BDamage_PetFromType + " Damage increases\n" +
                    "you pet's Attack Power by " + LC.CSS.BDamage_PetAP + "\n" +
                    "and Spell Damage by " + LC.CSS.BDamage_PetDamage;
                StatsPane[grid].Rows[1].Cells[i].ToolTipText =
                   "Bonus Healing\n" +
                   " Increases your healing by up to " + LC.CSS.BHealing;
                StatsPane[grid].Rows[2].Cells[i].ToolTipText =
                   "Hit Rating " + LC.CSS.Hit_Value + "\n" +
                   "  Increases your spell chance to hit a target of\n" +
                   "  (current level) by " + LC.CSS.Hit_Percent + "%";
                StatsPane[grid].Rows[3].Cells[i].ToolTipText =
                    "Crit Rating " + LC.CSS.Crit_Rating + '\n' + //need to eventually get min of all
                    " Holy              " + LC.CSS.Crit_Holy + "%\n" +
                    " Fire              " + LC.CSS.Crit_Fire + "%\n" +
                    " Nature            " + LC.CSS.Crit_Nature + "%\n" +
                    " Frost             " + LC.CSS.Crit_Frost + "%\n" +
                    " Shadow            " + LC.CSS.Crit_Shadow + "%\n" +
                    " Arcane            " + LC.CSS.Crit_Arcane + "%";
                StatsPane[grid].Rows[4].Cells[i].ToolTipText =
                   "Penetration\n" +
                   "Reduces the target's resistance to your spells";
                StatsPane[grid].Rows[5].Cells[i].ToolTipText =
                   "Mana Regen\n" +
                   LC.CSS.MP5_Noncast + " mana regenerated every 5 seconds while\n" +
                   "not casting\n" +
                   LC.CSS.MP5_Cast + " mana regenerated every 5 seconds while\n" +
                   "casting";

            }


        }
        private void UpdateBaseStats(int grid)
        {
            StatsPane[grid].Rows.Clear();
            StatsPane[grid].Rows.Add("Strength:", LC.CBS.str_effective);
            StatsPane[grid].Rows.Add("Agility:", LC.CBS.agi_effective);
            StatsPane[grid].Rows.Add("Stamina:", LC.CBS.sta_effective);
            StatsPane[grid].Rows.Add("Intellect:", LC.CBS.int_effective);
            StatsPane[grid].Rows.Add("Spirit:", LC.CBS.spi_effective);
            StatsPane[grid].Rows.Add("Armor:", LC.CBS.arm_effective);
            for (int i = 0; i < 2; i++)
            {
                StatsPane[grid].Rows[0].Cells[i].ToolTipText =
                   "Strength " + LC.CBS.str_effective + "(" + LC.CBS.str_base + "+" + (Convert.ToInt32(LC.CBS.str_effective) - Convert.ToInt32(LC.CBS.str_base)) + ")\n" +
                   " Increases Attack Power by " + LC.CBS.str_attack + "\n" +
                   " Increases Block by " + LC.CBS.str_block;
                StatsPane[grid].Rows[1].Cells[i].ToolTipText =
                   "Agility " + LC.CBS.agi_effective + "(" + LC.CBS.agi_base + "+" + (Convert.ToInt32(LC.CBS.agi_effective) - Convert.ToInt32(LC.CBS.agi_base)) + ")\n" +
                   " Increases Attack Power by " + LC.CBS.agi_attack + "\n" +
                   " Increases Critical Hit Chance by " + LC.CBS.agi_critHitPercent + "%\n" +
                   " Increases Armor by " + LC.CBS.agi_armor;
                StatsPane[grid].Rows[2].Cells[i].ToolTipText =
                   "Stamina " + LC.CBS.sta_effective + "(" + LC.CBS.sta_base + "+" + (Convert.ToInt32(LC.CBS.sta_effective) - Convert.ToInt32(LC.CBS.sta_base)) + ")\n" +
                   " Increases Health by " + LC.CBS.sta_health + "\n" +
                   " Increases Pet Staminia by " + LC.CBS.sta_petBonus;
                StatsPane[grid].Rows[3].Cells[i].ToolTipText =
                   "Intellect " + LC.CBS.int_effective + "(" + LC.CBS.int_base + "+" + (Convert.ToInt32(LC.CBS.int_effective) - Convert.ToInt32(LC.CBS.int_base)) + ")\n" +
                   " Increases Mana by " + LC.CBS.int_mana + "\n" +
                   " Increases Spell Critical Hit by " + LC.CBS.int_critHitPercent + "%\n" +
                   " Increases Pet Intellect by " + LC.CBS.int_petBonus;
                StatsPane[grid].Rows[4].Cells[i].ToolTipText =
                   "Spirit " + LC.CBS.spi_effective + "(" + LC.CBS.spi_base + "+" + (Convert.ToInt32(LC.CBS.spi_effective) - Convert.ToInt32(LC.CBS.spi_base)) + ")\n" +
                   " Increases Health Regeneration by " + LC.CBS.spi_healthRegen + " Per Secound\n" +
                   " while not in combat\n" +
                   " Increases Mana Regeneration by " + LC.CBS.spi_ManaRegen + " Per 5\n" +
                   " Secound while not casting";
                StatsPane[grid].Rows[5].Cells[i].ToolTipText =
                 "Armor  " + LC.CBS.arm_effective + "(" + LC.CBS.arm_base + "+" + (Convert.ToInt32(LC.CBS.arm_effective) - Convert.ToInt32(LC.CBS.arm_base)) + ")\n" +
                 " Reduces Physical Damage taken by " + LC.CBS.arm_percent + "%\n" +
                 " Increases your pet's armor by " + LC.CBS.arm_petBonus;
            }
        }
        private void UpdateDefenseStats(int grid)
        {
            StatsPane[grid].Rows.Clear();
            StatsPane[grid].Rows.Add("Armor:", LC.CDS.Arm_Effective);
            StatsPane[grid].Rows.Add("Defense:", LC.CDS.Def_Value);
            StatsPane[grid].Rows.Add("Dodge:", LC.CDS.Dodge_Percent + "%");
            StatsPane[grid].Rows.Add("Parry:", LC.CDS.Parry_Percent + "%");
            StatsPane[grid].Rows.Add("Block:", LC.CDS.Block_Percent + "%");
            StatsPane[grid].Rows.Add("Resilience:", LC.CDS.Res_Value);
            for (int i = 0; i < 2; i++)
            {
                StatsPane[grid].Rows[0].Cells[i].ToolTipText =
                    "Armor  " + LC.CDS.Arm_Effective + "(" + LC.CDS.Arm_Base + "+" + (Convert.ToInt32(LC.CDS.Arm_Effective) - Convert.ToInt32(LC.CDS.Arm_Base)) + ")\n" +
                 " Reduces Physical Damage taken by " + LC.CDS.Arm_Percent + "%\n" +
                 " Increases your pet's armor by " + LC.CDS.Arm_PetBonus;
                StatsPane[grid].Rows[1].Cells[i].ToolTipText =
                   "Defense " + LC.CDS.Def_Value + "\n" +
                   "Defense Rating " + LC.CDS.Def_Rating + " (+" + LC.CDS.Def_PlusDefense + " Defense)\n" +
                   "Increases chance to Dodge,Block and Parry by\n"+
                   LC.CDS.Def_IncreasePercent + "%\n" +
                   "Decreases chance to be hit and critically hit by\n"+
                   LC.CDS.Def_DecreasePercent + "%";
                StatsPane[grid].Rows[2].Cells[i].ToolTipText =
                    "Dodge Rating " + LC.CDS.Dodge_Rating + "\n" +
                    "Increases your chance to dodge by " + LC.CDS.Dodge_PlusPercent + "%";                
                StatsPane[grid].Rows[3].Cells[i].ToolTipText =
                    "Parry " + LC.CDS.Parry_Rating + "\n" +
                    "Increases your chance to dodge by " + LC.CDS.Parry_PlusPercent + "%";    
                StatsPane[grid].Rows[4].Cells[i].ToolTipText =
                    "Block Rating " + LC.CDS.Block_Rating + "\n" +
                    "Increases your chance to dodge by " + LC.CDS.Block_PlusPercent + "%";
                StatsPane[grid].Rows[5].Cells[i].ToolTipText =
                    "Resiliense " + LC.CDS.Res_Value + "\n" +
                    "Decreases chance of enemy scoring a critical hit\n" +
                    "on you by " + LC.CDS.Res_HitPercent + "%.\n" +
                    "Reduces damage taken from critical strikes by\n" +
                    LC.CDS.Res_DamagePercent + "%.\n" +
                    "Reduces damage taken from periodic damage by\n" +
                    LC.CDS.Res_HitPercent + "%.";
                 
            }
        }
        private void UpdateCharInfo()
        {
                LblTitle.Text = LC.CI.Prefix;
                LblName.Text = LC.CI.Name;
                LblGuild.Text = LC.CI.GuildName;
                LblLevelRaceClass.Text = "Level " + LC.CI.Level + " " + LC.CI.Race + " " + LC.CI.Class;
                PortraitIcon.Image = Image.FromFile(LC.CI.Level + "-" + LC.CI.PortraitFileName);

        }
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox2.SelectedIndex == 0)
            {
                UpdateBaseStats(1);
            }
            else if (comboBox2.SelectedIndex == 1)
            {
                UpdateMeleeStats(1);
            }
            else if (comboBox2.SelectedIndex == 2)
            {
                UpdateRangedStats(1);
            }
            else if (comboBox2.SelectedIndex == 3)
            {
                UpdateSpellStats(1);
            }
            else if (comboBox2.SelectedIndex == 4)
            {
                UpdateDefenseStats(1);
            }
            else
            {
            }

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                UpdateBaseStats(0);
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                UpdateMeleeStats(0);
            }
            else if (comboBox1.SelectedIndex == 2)
            {
                UpdateRangedStats(0);
            }
            else if (comboBox1.SelectedIndex == 3)
            {
                UpdateSpellStats(0);
            }
            else if (comboBox1.SelectedIndex == 4)
            {
                UpdateDefenseStats(0);
            }
            else
            {
            }


        }

        private void txtName_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void txtserver_TextChanged(object sender, EventArgs e)
        {

        }

        private void openFromWebToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (FRM.IsDisposed == true)
            {
                FRM = new LoadFromWeb();
                FRM.WowFrm = this;
                FRM.Show();
            }
            else
            {
                FRM.Show();
            }  
        }

        private void openFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Open Character File";
            openFileDialog1.Filter = "TEXT Files|*.Text";
            openFileDialog1.InitialDirectory = "C:\\";

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                GetCharcterFromFile();
            }
            else
            {

            }
        }

        private void WoWForm_Load(object sender, EventArgs e)
        {
            
        }
    }
}
